package Review;

public class Test49 {

	public static void main(String[] args) {
	    String str="+243";
        System.out.println(strToInt(str));
	}
	public static int strToInt(String str){
		boolean inputValid = false;
		if(str==null||str.length()==0||str==""){
			inputValid = true;
			return 0;
		}
		char[] ch=str.toCharArray();
		boolean minus=false;
		int i=0;
		if(ch[0]=='+'){
			i=1;
		}
		if(ch[0]=='-'){
			i=1;
			minus=true;
		}
		int sum=0;
		while(i<ch.length){
			if(ch[i]>='0'&&ch[i]<='9'){
				sum += (ch[i]-'0')*Math.pow(10.0, ch.length-i-1);
			}
			else{
				inputValid =true;
				return 0;
			}
			i++;
		}
		if(minus){
			sum=-sum;
		}
		return sum;
	}

}
